package com.ncp.servlet.registerlogin;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginAdminServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
   
		response.setContentType("text/html");
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		HttpSession session = request.getSession(true);
		session.setMaxInactiveInterval(10);
		String password = request.getParameter("password");
		String username = request.getParameter("username");
		/*System.out.println(password);
		System.out.println(username);*/
		if(password.equals("admin")&&username.equals("269743")){
			/*System.out.println("sss"+password);
			System.out.println("aaa"+username);*/
			session.setAttribute("username", username);
			request.getRequestDispatcher("pages/admin/AdminIndex.jsp").forward(request,response);
			
			
		}else{
			request.getRequestDispatcher("pages/admin/AdminIndex.jsp").forward(request,response);
			
		}
	}

}
